{% extends "SisGGFinalBundle:Usuario:user.html.twig" %}
{% block title %}Nueva Ciudad{% endblock %}
{% block name %}Kito's Local{% endblock%}
{% block descripcion %}Lorem ipsum ad his scripta blandit partiendo, eum fastidii accumsan euripidis in, eum liber hendrerit an. Qui ut wisi vocibus suscipiantur, quo dicit ridens inciderint id. Quo mundi lobortis reformidans eu, legimus senserit definiebas an eos. Eu sit tincidunt incorrupte definitionem, vis mutat affert percipit cu, eirmod consectetuer signiferumque eu per. In usu latine equidem dolores. Quo no falli viris intellegam, ut fugit veritus placerat per.{% endblock%}
{% block content %}
<form action="{{ path('altaCiudad') }}" method="post">
    <legend>Nueva Ciudad</legend>
        {% if error %}
    <div class="alert alert-error">
        <button type='button' class='close' data-dismiss='alert'>×</button>
        <strong>{{ error }}</strong> 
    </div>  
        {% endif %}
        {{ form_row(form.nombre) }} 
        {{ form_row(form.codigoPostal) }} 
    <div id="provinciasR" name="provinciasR">
        <label for="provincia">Provincia</label>
        {{ form_widget(form.provincia) }} 
        <a href="#prov" role="button" class="btn" data-toggle="modal">...</a>
    </div>           
    {{ form_rest(form) }} 
    <div class="form-actions">
        <button type="submit" class="btn btn-primary" >Guardar Cambios</button>
        <a href="{{path('ciudades')}}" type="button" class="btn">Cancelar</a>
    </div>        
</form>
<div id="prov" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">Agregar Provincia</h3>
    </div>
    <div class="modal-body">
        <form name="2" id="2" action="{{ path('altaPinC') }}" method="post">
            <label for="nomProv">Nombre</label>
            <input type="text" id="nomProv">
            <div class="modal-footer">
                <button class="btn btn-primary" type="button" onclick="cargarProv()"   class="btn btn-primary">Guardar</button>
                <button class="btn" id="btnCerrar" data-dismiss="modal" aria-hidden="true">Cerrar</button>
            </div>
        </form>
    </div>     
</div> 
{% endblock %}
{% block javascripts %}
    {{parent()}}

<script>
function cargarProv (){
             
     $('#provinciasR').load("{{ path('altaPinC')}}",{'nomProv':document.getElementById('nomProv').value},function() {
 document.getElementById('btnCerrar').onclick();
}); 
}
    </script>
{% endblock%}
